import express from 'express';
import * as complaintRouter from './complaint.controller';
import { fileInterceptor } from './complaint.middleware';
import { validateLoginData, authGuard, userGuard } from '../auth/auth.middleware';

const router = express.Router();

/**
 * 获取内容
 */
router.get('/complaint', complaintRouter.index);

/**
 * 获取内容(按 ID)
 */
router.get('/complaint/:postId', complaintRouter.complaintDetail);

/**
 * 创建内容
 */
router.post('/complaint', authGuard, complaintRouter.store);

/**
 * 更新内容
 */
router.patch('/complaint/:postId', authGuard, complaintRouter.update);

/**
 * 删除内容
 */
router.delete('/complaint/:postId', authGuard, complaintRouter.destroy);

/**
 * 上传文件
 */
router.post('/complaintFiles', authGuard, fileInterceptor, complaintRouter.uploads);

/**
 * 文件服务
 */
router.get('/complaintFiles/:fileId/serve', authGuard, complaintRouter.serve);

/**
 * 导出路由
 */
export default router;
